<div class="container">
  <section>
    <alert type="info" ng-hide="alertShow" close="alertShow = !alertShow"><strong>注意!</strong> 选择相应的报告来上传文件到该报告中.</alert>
    <h2>
      工作报告
      <div class="pull-right">
        <a ui-sref="app.reports-add">
          <small class="text-primary">
            <i class="fa fa-plus"></i>
            添加报告
          </small>
        </a>
      </div>
    </h2>
    <br/>
    <form class="form-inline clearfix">
      <div class="form-group">
        <select class="form-control" ng-model="year" ng-change="selectDate()">
          <option value="2013">2013年</option>
          <option value="2014">2014年</option>
          <option value="2015">2015年</option>
        </select>

        <div class="form-group">
          <select class="form-control" ng-model="month" ng-change="selectDate()">
            <option value="1">1月</option>
            <option value="2">2月</option>
            <option value="3">3月</option>
            <option value="4">4月</option>
            <option value="5">5月</option>
            <option value="6">6月</option>
            <option value="7">7月</option>
            <option value="8">8月</option>
            <option value="9">9月</option>
            <option value="10">10月</option>
            <option value="11">11月</option>
            <option value="12">12月</option>
          </select>
        </div>
        <div class="form-group">
          <select class="form-control" ng-model="$parent.currentUserId" ng-change="selectDate()"
                  ng-options="user._id as user.name group by user.department.name for user in users"
                  ng-if="currentUser.role == '总经理'"></select>
          <select class="form-control" ng-model="$parent.currentUserId" ng-change="selectDate()"
                  ng-options="user._id as user.name group by user.department.name for user in users | filter: currentUser.department.name"
                  ng-if="currentUser.role == '部门主管'"></select>
          <select class="form-control" ng-model="$parent.currentUserId" ng-change="selectDate()"
                  ng-options="user._id as user.name group by user.department.name for user in users | filter: currentUser.name"
                  ng-if="currentUser.role == '普通员工'"></select>
        </div>
      </div>
      <button ng-file-select ng-model="reportFile" ng-file-change="upload()" ng-show="reports.length"  multiple="false" class="btn btn-primary pull-right">上传资料</button> <span class="text-center"> {{progressStatus}} </span><span ng-show="progress" class="text-center">{{nowProgress}}</span>

    </form>

    <div class="row" ng-if="reports.length">
      <div class="col-md-6 col-md-push-6" class="animated fadeInRight">
        <p style="margin: 5px 0 12px 0; padding-bottom: 9px; border-bottom: 2px solid #E7E7E7;"><strong>
          {{reports[$reportIndex].user.name}}的工作报告
        </strong>
        </p>
        <div class="panel panel-default">
          <div class="panel-heading">
            项目名
          </div>
          <div class="panel-body slide">{{reports[$reportIndex].title}}</div>
        </div>

        <div class="panel panel-default">
          <div class="panel-heading">
            日期
          </div>
          <div class="panel-body slide">{{reports[$reportIndex].date | date: 'EEEE, yyyy-MM-dd'}}</div>
        </div>

        <div class="panel panel-default">
          <div class="panel-heading">
            工作报告
          </div>
          <div class="panel-body slide">{{reports[$reportIndex].body}}</div>
        </div>

        <div class="panel panel-default">
          <div class="panel-heading">
            明日计划
          </div>
          <div class="panel-body slide">{{reports[$reportIndex].plan}}</div>
        </div>

        <div class="panel panel-default" ng-if="reports[$reportIndex].notes">
          <div class="panel-heading">
            备注
          </div>
          <div class="panel-body slide">{{reports[$reportIndex].notes}}</div>
        </div>

        <div class="panel panel-default" ng-if="reports[$reportIndex].files.length">
          <div class="panel-heading">
            附件列表
          </div>
          <div class="panel-body slide">
            <ul>
              <li ng-repeat="file in reports[$reportIndex].files">
                <a href="{{file.file_path}}">{{file.file_name}}</a> <button style="background: none;border: none;color: red" ng-click="removeFile(file._id, $index)" ng-if="currentUser.department.name=='综合部'"><i class="fa fa-times"></i></button>
              </li>
            </ul>
          </div>
        </div>

        <button type="button" class="btn btn-danger pull-right" ng-click="delete(reports[$reportIndex]._id)">删除
        </button>

      </div>

      <div class="col-md-6 col-md-pull-6" class="animated fadeInLeft">
        <div class="table-responsive">
          <table class="table table-hover">
            <thead>
            <tr>
              <th>日期</th>
              <th>项目</th>
              <th>类型</th>
              <th>备注</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="report in reports"style="cursor: pointer" ng-click="selectProject($index)"  ng-class="{'active': $reportIndex == $index}">
              <td>{{report.date | date: 'MM-dd'}}</td>
              <td>{{report.title}}</td>
              <td>
                {{report.type}}
              </td>
              <td>
                <span class="text-danger glyphicon glyphicon-remove" ng-if="!report.notes.length"></span>
                <span class="text-success glyphicon glyphicon-ok" ng-if="report.notes.length"></span>
              </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
              <th>日期</th>
              <th>项目</th>
              <th>类型</th>
              <th>备注</th>
            </tr>
            </tfoot>
          </table>
        </div>
      </div>
    </div>

    <div class="row" ng-if="!reports.length">
      <p class="lead text-center" style="margin: 50px auto"><i class="fa fa-exclamation-triangle"></i> 找不到该月的记录！</p>
    </div>
  </section>
</div>
